package com.zz.parkingsystem.service.impl;

import com.zz.parkingsystem.entity.OrderItem;
import com.zz.parkingsystem.entity.User;
import com.zz.parkingsystem.entity.UserFeedback;
import com.zz.parkingsystem.mapper.OrderItemMapper;
import com.zz.parkingsystem.mapper.UserFeedbackMapper;
import com.zz.parkingsystem.mapper.UserMapper;
import com.zz.parkingsystem.service.UserFeedbackService;
import com.zz.parkingsystem.util.NumberUtil;
import com.zz.parkingsystem.vo.ShowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class UserFeedbackServiceImpl implements UserFeedbackService {
    @Autowired
    private UserFeedbackMapper userFeedbackMapper;
    @Autowired
    private OrderItemMapper orderItemMapper;
    @Autowired
    private UserMapper userMapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return userFeedbackMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(UserFeedback record) {
        return userFeedbackMapper.insert(record);
    }

    @Override
    public int insertSelectiveUser(UserFeedback record) {
        Integer userId = record.getAccId();
        User user = userMapper.selectByPrimaryKey(userId.longValue());
        record.setAccId(user.getAccId());
        record.setUfFeedbackTime(new Date());
        record.setUfNo(NumberUtil.genOrderNo());
        return userFeedbackMapper.insertSelective(record);
    }

    @Override
    public UserFeedback selectByPrimaryKey(Long id) {
        return userFeedbackMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(UserFeedback record) {
        return userFeedbackMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(UserFeedback record) {
        return userFeedbackMapper.updateByPrimaryKey(record);
    }
}
